#include <APGCLI.H>

#include <MrLockUi.rsg>

#include "ApplicationDetailsDialog.h"
#include "Utils.h"

CApplicationDetailsDialog::CApplicationDetailsDialog()
{
	
}

TBool CApplicationDetailsDialog::RunDlgLD(TUid aAppUid)
{
	if (aAppUid.iUid < 300)
		return EFalse;

	RApaLsSession lsSession;
	lsSession.Connect();
	CleanupClosePushL(lsSession);//+lsSession
	TApaAppInfo appInfo;
	lsSession.GetAppInfo(appInfo, aAppUid);
	CleanupStack::PopAndDestroy();//-lsSession

	HBufC* text = HBufC::NewLC(500);
	text->Des().AppendFormat(_L("UID: 0x%08x\n"), aAppUid.iUid);
	text->Des().AppendFormat(_L("%S: %S\n"), &Utils::GetR(R_TEXT_APPNAME), &appInfo.iCaption);
	text->Des().AppendFormat(_L("%S: %S\n"), &Utils::GetR(R_TEXT_APPSHORTNAME), &appInfo.iShortCaption);
	text->Des().AppendFormat(_L("%S: %S\n"), &Utils::GetR(R_TEXT_APPPATH), &appInfo.iFullName);
	CApplicationDetailsDialog* dlg = new (ELeave) CApplicationDetailsDialog();

	dlg->PrepareLC(R_APPLICATION_DETAILS_DIALOG);
	dlg->SetMessageText(*text);
	TBool res = dlg->RunLD();
	CleanupStack::PopAndDestroy();
	if (res)
	{//start the app
		Utils::StartExeL(aAppUid);
		return ETrue;
	}
	return EFalse;
}

TBool CApplicationDetailsDialog::OkToExitL(TInt)
{
	return ETrue;
}